#include<iostream>
using namespace std;
int b[101][101]={0};
int main(){
int x,y;
cin>>x>>y;
string a;
int i,j;
for(i=1;i<=x;i++){
	cin>>a;
	j=0;
	while(a[j]!='\0'){
		if(a[j]=='*') b[i][j+1]=1;
		j++; 
	};
};
for(i=1;i<=x;i++){
	for(j=1;j<=y;j++){
		if(b[i][j]==0) cout<<b[i][j-1]+b[i][j+1]+b[i-1][j]+b[i+1][j]
						+b[i+1][j+1]+b[i+1][j-1]+b[i-1][j+1]+b[i-1][j-1];
		else cout<<"*";
	};
	cout<<endl;
};
return 0;
}
